﻿<?xml version="1.0" encoding="utf-8" ?>

<cls:class
	name="Boolean"
	type="http://metalx.org/Boolean"
	static="true"
	xmlns="http://metalx.org/Program"
	xmlns:cls="http://metalx.org/Class"
	xmlns:bool="http://metalx.org/i386/Functions/Boolean"
	xmlns:obj="http://metalx.org/i386/Functions/Object"
	xmlns:lst="http://metalx.org/i386/Functions/List"
	xmlns:str="http://metalx.org/i386/Functions/String"
	xmlns:mm="http://metalx.org/i386/Functions/MemoryManager"
	xmlns:clsf="http://metalx.org/i386/Functions/Class"
	xmlns:var="http://metalx.org/Variable"
	xmlns:sys="http://metalx.org/i386/Functions/System"
	xmlns:cat="http://metalx.org/i386/Functions/Catalog"
	xmlns:asc="http://metalx.org/Ansi/Ascii"
	xmlns:ari="http://metalx.org/Intel/80386/Arithmetic"
	xmlns:math="http://metalx.org/Intel/80386/Math"
	xmlns:cpu="http://metalx.org/Intel/80386/Operators"
	xmlns:op="http://metalx.org/Intel/80386/Operands">

	<cls:field name="Value" type="http://metalx.org/Boolean" offset="0"/>

	<cls:method name="True" type="http://metalx.org/Boolean" static="true">
		<cpu:CopyImmediateToAL/>
		<byte>1</byte>
		
		<bool:CreateObject/>

		<cpu:ReturnToNearCaller/>
	</cls:method>

	<cls:method name="False" type="http://metalx.org/Boolean" static="true">
		<cpu:CopyImmediateToAL/>
		<byte>0</byte>

		<bool:CreateObject/>

		<cpu:ReturnToNearCaller/>
	</cls:method>

	<cls:method name="Parse" type="http://metalx.org/Boolean" static="true">
		<cls:parameter name="Value" type="http://metalx.org/String"/>

		<cpu:ExchangeOperandWithRegister/>
		<op:BP-SPRegister/>

		<cpu:PullSIFromStack/>

		<cpu:ExchangeOperandWithRegister/>
		<op:BP-SPRegister/>

		<obj:GetData/>

		<cpu:CopyRegisterToOperand/>
		<op:SI-DXRegister/>

		<cpu:CopyImmediateToDI/>
		<addressOf ref="trueString" type="Absolute32"/>

		<str:Compare/>

		<cpu:BranchToRelative8IfEqual/>
		<addressOf ref="true" type="Relative8"/>

		<cpu:CopyRegisterToOperand/>
		<op:DX-SIRegister/>

		<cpu:CopyImmediateToDI/>
		<addressOf ref="trueStringLower" type="Absolute32"/>

		<str:Compare/>

		<cpu:BranchToRelative8IfEqual/>
		<addressOf ref="true" type="Relative8"/>

		<cpu:CopyImmediateToAL/>
		<byte>0</byte>

		<cpu:JumpToRelative8/>
		<addressOf ref="createObject" type="Relative8"/>

		<label id="true"/>

		<cpu:CopyImmediateToAL/>
		<byte>1</byte>

		<label id="createObject"/>

		<bool:CreateObject/>

		<cpu:ReturnToNearCaller/>
	</cls:method>

	<cls:method name="ToString" type="http://metalx.org/String">
			<cpu:CopyRegisterToOperand/>
		<op:DI-SIRegister/>

		<obj:GetData/>

		<cpu:MathImmediateToOperandFunction8/>
		<math:CompareWithSIAddress/>
		<byte>0</byte>

		<cpu:BranchToRelative8IfEqual/>
		<addressOf ref="false" type="Relative8"/>

		<cpu:CopyImmediateToDI/>
		<addressOf ref="trueString" type="Absolute32"/>

		<cpu:JumpToRelative8/>
		<addressOf ref="createObject" type="Relative8"/>

		<label id="false"/>
		
		<cpu:CopyImmediateToDI/>
		<addressOf ref="falseString" type="Absolute32"/>

		<label id="createObject"/>

		<str:CreateObject/>

		<cpu:CopyRegisterToOperand/>
		<op:DI-SIRegister/>

		<cpu:ReturnToNearCaller/>
	</cls:method>

	<cls:method name="GetClass" type="http://metalx.org/Class">
		<cpu:CopyRegisterToOperand/>
		<op:DI-SIRegister/>

		<obj:GetType/>

		<cpu:CopyRegisterToOperand/>
		<op:SI-DIRegister/>

		<clsf:CreateObject/>

		<cpu:ReturnToNearCaller/>
	</cls:method>

	<cls:method name="GetClass" type="http://metalx.org/Class" static="true">
		<cpu:CopyRegisterToOperand/>
		<op:BX-DIRegister/>

		<clsf:CreateObject/>

		<cpu:ReturnToNearCaller/>
	</cls:method>

	<var:string id="falseString">False</var:string>
	<var:string id="trueString">True</var:string>
	<var:string id="falseStringLower">false</var:string>
	<var:string id="trueStringLower">true</var:string>
</cls:class>